// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Data;
using SnapObjects.Commons;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Defines a parameter with name and type in the model class.
    /// </summary>
    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = true, Inherited = true)]
    public class SqlParameterAttribute : Attribute, ISqlParameter
    {
        /// <summary>
        ///     Initializes a new instance of the SqlParameterAttribute class.
        /// </summary>
        /// <param name="name">The name of the parameter.</param>
        /// <param name="dataType">The data type of the parameter.</param>
        public SqlParameterAttribute(string name, Type dataType)
        {
            this.Name = name;
            this.DataType = dataType;

            Check.NotEmpty(name, nameof(name));
            Check.NotNull(dataType, nameof(dataType));
        }

        /// <summary>
        ///     Gets the name of the parameter.
        /// </summary>
        public string Name { get; }

        /// <summary>
        ///     Gets the data type of the parameter.
        /// </summary>
        public Type DataType { get; }

        /// <summary>
        ///     Gets the direction type of the parameter.
        /// </summary>
        public ParameterDirection Direction => ParameterDirection.Input;
    }
}
